<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link th:href="@{/css/bootstrap.min.css}" rel="stylesheet"/>
    <script th:src="@{/js/jquery.min.js}"></script>
    <script th:src="@{/js/bootstrap.min.js}"></script>
</head>
<body>
<div class="container">
    <div class="page-header">
        <h3>请选择歌曲类型和歌手</h3>
    </div>
    <div class="row">
        <form class="form-inline" action="#">
            <label>类型：</label>
            <select name="type" class="selectpicker form-control input-sm">
                <option value="all">全部</option>
                <option th:selected="${type eq s_type}" th:each="type : ${typeList}" th:value="${type}" th:text="${type}"></option>
            </select>
            <label>歌手：</label>
            <select name="singer" class="selectpicker form-control input-sm">
                <option value="all">全部</option>
                <option th:selected="${singer eq s_singer}" th:each="singer : ${singerList}" th:value="${singer}" th:text="${singer}"></option>
            </select>
            <button type="submit" class="btn btn-sm btn-primary" id="search_btn">查询歌曲</button>
            <button type="button" class="btn btn-sm btn-primary" id="pdf">生成pdf</button>
        </form>
    </div>
    <div class="input-sm"></div>
    <table id="contentTable" class="table table-striped table-bordered table-hover">
        <thead>
        <tr>
            <th>歌名</th>
            <th>时长</th>
            <th>类型</th>
            <th>歌手</th>
        </tr>
        </thead>
        <tbody>
        <tr th:each="music : ${musicList}">
            <td th:text="${music.getMusicName()}"></td>
            <td th:text="${music.getMusicTime()}"></td>
            <td th:text="${music.getMusicType()}"></td>
            <td th:text="${music.getMusicSinger()}"></td>
        </tr>
        </tbody>
    </table>
</div>
<script type="text/javascript">
    $('#pdf').on('click', function () {
        alert(window.location.href);
        createPdf();
    });

    function createPdf() {
        $.ajax({
            type: "post",
            url: "/pdf?url=" + window.location.href,
            success: function(data) {
                alert(data);
            }
        });
    }
</script>
</body>
</html>
